
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/07/2012 17:45:20
-- Generated from EDMX file: C:\Coding\Projects\MoneyBooker\MoneyBookerDB\MoneyDB.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [rigole22_MoneyBooker];
GO
IF SCHEMA_ID(N'ac') IS NULL EXECUTE(N'CREATE SCHEMA [ac]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[ac].[Banks]', 'U') IS NOT NULL
    DROP TABLE [ac].[Banks];
GO
IF OBJECT_ID(N'[ac].[Accounts]', 'U') IS NOT NULL
    DROP TABLE [ac].[Accounts];
GO
IF OBJECT_ID(N'[ac].[Transactions]', 'U') IS NOT NULL
    DROP TABLE [ac].[Transactions];
GO
IF OBJECT_ID(N'[ac].[TransactionLog]', 'U') IS NOT NULL
    DROP TABLE [ac].[TransactionLog];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Banks'
CREATE TABLE [ac].[Banks] (
    [id] int IDENTITY(1,1) NOT NULL,
    [name] nvarchar(max)  NOT NULL,
    [lastUpdate] datetime  NOT NULL,
    [website] nvarchar(max)  NULL,
    [logo] varbinary(max)  NOT NULL,
    [bic] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Accounts'
CREATE TABLE [ac].[Accounts] (
    [id] int IDENTITY(1,1) NOT NULL,
    [name] nvarchar(max)  NULL,
    [iban] nvarchar(max)  NOT NULL,
    [bankId] int  NOT NULL,
    [balance] float  NOT NULL
);
GO

-- Creating table 'Transactions'
CREATE TABLE [ac].[Transactions] (
    [id] int IDENTITY(1,1) NOT NULL,
    [from] int  NULL,
    [to] int  NULL,
    [amount] float  NOT NULL,
    [message] nvarchar(max)  NOT NULL,
    [date] datetime  NOT NULL,
    [valuta] datetime  NOT NULL
);
GO

-- Creating table 'TransactionLog'
CREATE TABLE [ac].[TransactionLog] (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [transaction] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [id] in table 'Banks'
ALTER TABLE [ac].[Banks]
ADD CONSTRAINT [PK_Banks]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Accounts'
ALTER TABLE [ac].[Accounts]
ADD CONSTRAINT [PK_Accounts]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Transactions'
ALTER TABLE [ac].[Transactions]
ADD CONSTRAINT [PK_Transactions]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'TransactionLog'
ALTER TABLE [ac].[TransactionLog]
ADD CONSTRAINT [PK_TransactionLog]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------